Copyright: Copyright © 1998-1999 Carl L. Roth. All rights reserved.


CLR Script Help Index

Thank you for evaluating CLR Script™!  I hope you find the program very useful.

How To...

Run a script file from a shortcut

Language Reference

CLR Script Language Reference

Commands

File menu

Edit menu

View menu

Build menu

Tools menu

Window menu

Help menu

Information

Revision History

License Agreement

Registration Information

CLR Script is Shareware.  Unregistered users are granted a limited license to evaluate CLR Script for 30 days.  Please read the License Agreement and Registration Information in the help.

Copyright © 1998-1999 Carl L. Roth. All rights reserved.

CLR Script is a trademark of Carl L. Roth

Carl L. Roth

P.O. Box 6613

Champaign, IL 61826

USA

clroth@prairienet.org

http://www.prairienet.org/~clroth/clrscript.html


File menu commands

The File menu offers the following commands:

New	Creates a new script file.
Open	Opens an existing script file.
Close	Closes an opened script file.
Save	Saves an opened script file using the same file name.
Save As	Saves an opened script file to a specified file name.
Save All	Saves all the modified open script files.
Print	Prints the active script file.
Print Preview	Displays the script file on the screen as it would appear printed.
Print Setup	Selects a printer and printer connection.
Exit	Exits CLR Script.


Edit menu commands

The Edit menu offers the following commands:

Undo	Undo last action.
Cut	Cut the selection and put it on the Clipboard
Copy	Copy the selection and put it on the Clipboard.
Paste	Insert Clipboard contents.
Find	Find the specified text.
Replace	Replace specific text with different text.


View menu commands

The View menu offers the following commands:

Toolbar	Shows or hides the toolbar.
Status Bar	Shows or hides the status bar.


Window menu commands

The Window menu offers the following commands, which enable you to arrange multiple views of multiple script files in the application window:

New Window	Open another window for the active script file.
Cascade	Arranges windows in an overlapped fashion.
Tile	Arranges windows in non-overlapped tiles.
Arrange Icons	Arranges icons of minimized windows.
Window 1, 2, ...	Goes to specified window.


Help menu commands

The Help menu offers the following commands, which provide you assistance with this application:

Help Topics	Offers you an index to topics on which you can get help.
Language Reference	Read the language reference help.
Register CLR Script	Register your copy of CLR Script.
Registration Number	Enter your Registration Number for CLR Script.
About	Display program information, version number and copyright.


File New command
New command (File menu)

Use this command to create a new script file in CLR Script.

You can open an existing script file with the Open command.

Shortcuts

Toolbar:

Keys:	CTRL+N


File Open command
Open command (File menu)

Use this command to open an existing script file in a new window.  You can open multiple script files at once.  Use the Window menu to switch among the multiple open script files.  See Window 1, 2, ... command.

You can create new script files with the New command.

Shortcuts

Toolbar:

Keys:	CTRL+O


File Close command
Close command (File menu)

Use this command to close all windows containing the active script file.  CLR Script suggests that you save changes to your script file before you close it.  If you close a script file without saving, you lose all changes made since the last time you saved it.  Before closing an untitled script file, CLR Script displays the Save As dialog box and suggests that you name and save the script file.

You can also close a script file by using the Close icon on the script file's window, as shown below:


File Save command
Save command (File menu)

Use this command to save the active script file to its current name and directory.  When you save a script file for the first time, CLR SCript displays the Save As dialog box so you can name your script file.  If you want to change the name and directory of an existing script file before you save it, choose the Save As command.

Shortcuts

Toolbar:

Keys:	CTRL+S


File Save As command
Save As command (File menu)

Use this command to save and name the active script file.  CLR Script displays the Save As dialog box so you can name your script file.

To save a script file with its existing name and directory, use the Save command.


File 1, 2, 3, 4 command
1, 2, 3, 4 command (File menu)

Use the numbers and file names listed at the bottom of the File menu to open the last script files you closed.  Choose the number that corresponds with the script file you want to open.


Exit command (File menu)

Use this command to end your CLR Script session.  You can also use the Close command on the application Control menu.  CLR Script prompts you to save script files with unsaved changes.

Shortcuts

Mouse:	Double-click the application's Control menu button.

Keys:	ALT+F4


Undo command (Edit menu)

Use this command to reverse the last editing action, if possible.  The Undo command is disabled on the menu if you cannot reverse your last action.

Shortcuts

Keys:	CTRL+Z or

ALT-BACKSPACE


Cut command (Edit menu)

Use this command to remove the currently selected text and put it on the clipboard.  This command is unavailable if there is no text currently selected.

Cutting text to the clipboard replaces the contents previously stored there.

Shortcuts

Toolbar:

Keys:	CTRL+X


Copy command (Edit menu)

Use this command to copy the currently selected text onto the clipboard.  This command is unavailable if there is no text currently selected.

Copying text to the clipboard replaces the contents previously stored there.

Shortcuts

Toolbar:

Keys:	CTRL+C


Paste command (Edit menu)

Use this command to insert a copy of the clipboard text contents.  This command is unavailable if the clipboard is empty.

Shortcuts

Toolbar:

Keys:	CTRL+V


Toolbar command (View menu)

Use this command to display and hide the Toolbar, which includes buttons for some of the most common commands in CLR Script, such as File Open.  A check mark appears next to the menu item when the Toolbar is displayed.

See Toolbar for help on using the toolbar.


Toolbar

The main toolbar is displayed across the top of the application window, below the menu bar.  The toolbar provides quick mouse access to many tools used in CLR Script.

To hide or display the Toolbar, choose Toolbar from the View menu (ALT, V, T).

Click	To

Open a new script file.

Open an existing script file.  CLR Script displays the Open dialog box, in which you can locate and open the desired file.

Save the active script file with its current name.  If you have not named the script file, CLR Script displays the Save As dialog box.

Prints the current script file directly to the printer.

Cut the current selection and put it on the Clipboard

Copy the current selection and put it on the Clipboard.

Insert the Clipboard contents.

Compile the active script file.

Run the active script file.

Display program information, version number and copyright.

Display help for clicked on buttons, menus and windows.

List Help topics.


View Status Bar Command
Status Bar command (View menu)

Use this command to display and hide the Status Bar, which describes the action to be executed by the selected menu item or depressed toolbar button, and keyboard latch state.  A check mark appears next to the menu item when the Status Bar is displayed.

See Status Bar for help on using the status bar.


Status Bar

The status bar is displayed at the bottom of the CLR Script window.  To display or hide the status bar, use the Status Bar command in the View menu.

The left area of the status bar describes actions of menu items as you use the arrow keys to navigate through menus.  This area similarly shows messages that describe the actions of toolbar buttons as you depress them, before releasing them.  If after viewing the description of the toolbar button command you wish not to execute the command, then release the mouse button while the pointer is off the toolbar button.

The right areas of the status bar indicate which of the following keys are latched down:

Indicator	Description

CAP	The Caps Lock key is latched down.

NUM	The Num Lock key is latched down.


New command (Window menu)

Use this command to open a new window with the same contents as the active window.  You can open multiple document windows to display different parts or views of a document at the same time.  If you change the contents in one window, all other windows containing the same document reflect those changes.  When you open a new window, it becomes the active window and is displayed on top of all other open windows.


Cascade command (Window menu)

Use this command to arrange multiple opened windows in an overlapped fashion.


Tile command (Window menu)

Use this command to arrange multiple opened windows in a non-overlapped fashion.


Arrange Icons command (Window menu)

Use this command to arrange the icons for minimized windows at the bottom of the main window.  If there is an open script file window at the bottom of the main window, then some or all of the icons may not be visible because they will be underneath this script file window.


1, 2, ... command (Window menu)

CLR Script displays a list of currently open script file windows at the bottom of the Window menu.  A check mark appears in front of the script file name of the active window.  Choose a script file from this list to make its window active.


Help Topics command (Help menu)

Use this command to display the opening screen of Help.  From the opening screen, you can jump to step-by-step instructions for using CLR Script and various types of reference information.

Once you open Help, you can click the Contents button whenever you want to return to the opening screen.

Shortcut

Toolbar:


About command (Help menu)

Use this command to display the copyright notice and version number of your copy of CLR Script.

Shortcut

Toolbar:


Context Help command

Use the Context Help command to obtain help on some portion of CLR Script.  When you choose the Toolbar's Context Help button, the mouse pointer will change to an arrow and question mark.  Then click somewhere in the CLR Script window, such as another Toolbar button.  The Help topic will be shown for the item you clicked.

Shortcuts

Toolbar:

Keys:	SHIFT+F1


Title Bar

The title bar is located along the top of a window.  It contains the name of the application and script file.

To move the window, drag the title bar.  Note: You can also move dialog boxes by dragging their title bars.

A title bar may contain the following elements:

Application Control-menu button

Script file Control-menu button

Maximize button

Minimize button

Name of the application

Name of the script file

Restore button


Scroll bars

Displayed at the right and bottom edges of the script file window.  The scroll boxes inside the scroll bars indicate your vertical and horizontal location in the script file.  You can use the mouse to scroll to other parts of the script file.


Size command (System menu)

Use this command to display a four-headed arrow so you can size the active window with the arrow keys.

After the pointer changes to the four-headed arrow:

1.	Press one of the DIRECTION keys (left, right, up, or down arrow key) to move the pointer to the border you want to move.

2.	Press a DIRECTION key to move the border.

3.	Press ENTER when the window is the size you want.

Note:  This command is unavailable if you maximize the window.

Shortcut

Mouse:	Drag the size bars at the corners or edges of the window.


Move command (Control menu)

Use this command to display a four-headed arrow so you can move the active window or dialog box with the arrow keys.

Note:  This command is unavailable if you maximize the window.


System Minimize Command
Minimize command (application Control menu)

Use this command to reduce the CLR Script window to an icon.

Shortcut

Mouse:	Click the minimize icon [image] on the title bar.


Maximize command (System menu)

Use this command to enlarge the active window to fill the available space.

Shortcut

Mouse:	Click the maximize icon [image] on the title bar; or double-click the title bar.


Next command (script file Control menu)

Use this command to switch to the next open script file window.  CLR Script determines which window is next according to the order in which you opened the windows.

Shortcut

Keys:	CTRL+F6


Close command (Control menus)

Use this command to close the active window or dialog box.

Double-clicking a Control-menu box is the same as choosing the Close command.

Note:  If you have multiple windows open for a single script file, the Close command on the script file Control menu closes only one window at a time.  You can close all windows at once with the Close command on the File menu.

Shortcuts

Keys: 	CTRL+F4 closes a script file window

ALT+F4 closes the CLR Script window or dialog box


Restore command (Control menu)

Use this command to return the active window to its size and position before you chose the Maximize or Minimize command.


Modifying the Script File

A script file is simply a text file with special instructions to control what your computer does.

To test compile the active script file, select the Compile command from the Build menu.

To compile then run the active script file, select the Run command from the Build menu.


No Help Available

No help is available for this area of the window.


No Help Available

No help is available for this message box.


Print command (File menu)

Use this command to print a script file.  This command presents a Print dialog box, where you may specify the range of pages to be printed, the number of copies, the destination printer, and other printer setup options.

Note: The toolbar button prints directly to the printer using the current defaults.

Shortcuts

Toolbar:

Keys:	CTRL+P


Print Progress Dialog

The Printing dialog box is shown during the time that CLR Script is sending output to the printer.  The page number indicates the progress of the printing.

To abort printing, choose Cancel.


Print Preview command (File menu)

Use this command to display the active script file as it would appear when printed.  When you choose this command, the main window will be replaced with a print preview window in which one or two pages will be displayed in their printed format.  The Print Preview toolbar offers you options to view either one or two pages at a time; move back and forth through the pages; zoom in and out of pages; and initiate a print job.


Print Preview toolbar

The Print Preview toolbar offers you the following options:

Print

Bring up the print dialog box, to start a print job.

Next Page

Preview the next printed page.

Prev Page

Preview the previous printed page.

One Page / Two Page

Preview one or two printed pages at a time.

Zoom In

Take a closer look at the printed page.

Zoom Out

Take a larger look at the printed page.

Close

Return from Print Preview to the editing window.


Print Setup command (File menu)

Use this command to select a printer and a printer connection.  This command presents a Print Setup dialog box, where you specify the printer and its connection.


Revision History

Version 1.23

Added the IsServiceActive function.

Fixed and improved a few aspects of the script engine.

Improved the help.

Version 1.22

Added the ComboBox_SelectString function.

Added the ListBox_SelectString function.

Added the ability to run CLR Script without installing the program by adding the switch “/n” to the command line.

Fixed and improved a few aspects of the script engine.

Version 1.21

Added the break statement.

Added the repeat statement.

Added the while statement.

Fixed and improved a few aspects of the script engine.

Fixed a few problems with the installation.

Improved the help.

Version 1.20

Added the BrowseURL function.

Added the CreateFile function.

Added the DeleteFile function.

Added the FileExists function.

Added the ability to run a script without displaying the progress dialog window by adding the switch “/h” to the command line.

Fixed a few bugs in the script engine.

Fixed getting help for dialog boxes by pressing F1.

Version 1.13

Added the RegCreateKey function.

Added the RegDeleteKey function.

Added the RegDeleteKeyValue function.

Added the RegSetKeyValueInt function.

Added the RegSetKeyValueString function.

Added the HKEY type specifier.

Fixed and improved a few aspects of the script engine.

Improved the help.

Version 1.12

Added the itoa function.

Added the operators +, -, *, /, &, ||, and &&.

Added the string operator + to concatenate strings.

Fixed and improved a few aspects of the script engine.

Version 1.11

Added the NetUserChangePassword function.

Added the SetForegroundWindowTitleSub function.

Added the Window Information Finder command.

Fixed and improved a few aspects of the script engine.

Improved the help.

Version 1.10

Added the ClickButton function.

Added the CopyToClipboard function.

Added the EmptyClipboard function.

Added the exit function.

Added the SetDlgItemText function.

Added the WaitWindowClosed function.

Added the #include statement.

Added the string special character ‘\r’.

Added the ability to continue long string constants onto the next line by ending the line with a backward slash ‘\’.

Added the Find command.

Added the Replace command.

Pressing F1 when the cursor is on a keyword brings up help for that word.

Added the ability to run a script from a shortcut by adding the switch “/r” to the command line.

New lines are automatically indented to the previous line.

Pressing the tab key with multiple lines selected indents the lines.

Pressing the shift+tab keys with multiple lines selected unindents the lines.

When opening a script file from the command line, if the file does not exist, you will be asked if you would like to create a new file.

When running or compiling, all the modified open files are automatically saved.

Fixed and improved many aspects of the script engine.

Improved the error reporting.

Improved the help.

Version 1.0

First public release of CLR Script.

Added the Run command.

Added the Compile command.

The editor is a simple edit control similar to Notepad.

Added the CheckDlgButton function.

Added the FindWindow function.

Added the IsEmpty function.

Added the MessageBox function.

Added the Pause function.

Added the Run function.

Added the SendKeys function.

Added the SetForegroundWindow function.

Added the VerifyActiveWindowText function.

Added the VerifyActiveWindowTitle function.

Added the VerifyActiveWindowTitleSub function.

Added the WaitWindowTitleVisible function.

Added the int type specifier.

Added the string type specifier.

Added the void type specifier.

Added the negation “!” operator.

Added the bitwise or “|” operator.

Added the constant TRUE.

Added the constant FALSE.


Registration Form

To register CLR Script, send the following information along with your credit card information, a check, money order, or cash (US funds drawn from a US bank, payable to Carl L. Roth).  Site licenses can be purchased using a company purchase order.  If you are registering more than one single user license, you may optionally submit forms for each additional user.  Site licenses will be registered under the company name.  Please print or type clearly.  Especially the email address since that is my main form of communication to you.

1.	Registration Fee	Price	Quantity	Total

1 to 4 Single User Licenses	$20.00	each	________	________

5 User Site License	$90.00	________	________

25 User Site License	$350.00	________	________

100 User Site License	$1,000.00	________	________

Unlimited US Site License	$2,000.00	________	________

Unlimited Worldwide Site License	$3,000.00	________	________

2.	Name:	________________________________________________________________

3.	Company:	________________________________________________________________

4.	Address:	________________________________________________________________

5.	City:	________________________________________________________________

6.	State/Province:	________________________________________________________________

7.	Zip/Postal Code:	________________________________________________________________

8.	Country:	________________________________________________________________

9.	Email Address:	________________________________________________________________

10.	Phone:	________________________________________________________________

11.	Current version number of CLR Script: Version 1.23

12.	Where did you find out about CLR Script?

[  ] CLR Shareware	[  ] Download.com

[  ] Dave Central	[  ] SoftSeek

[  ] SoftWatcher	[  ] TUCOWS

[  ] WinFiles.com	[  ] ZDNet Software Library

[  ] Other:	________________________________________________________________

13.	Any enhancements to CLR Script you would like to see (optional):

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

14.	Payment Method:	[  ] Check    [  ] Money Order    [  ] Cash    [  ] Purchase Order

Credit Card:	[  ] Visa	[  ] Mastercard     [  ] Discover (Novus)

[  ] American Express	[  ] Eurocard

Name on Card:	________________________________

Card Number:	________________________________     Expiration Date: __________

Send to:	Carl L. Roth

P.O. Box 6613

Champaign, IL 61826

USA

If you are paying by credit card, you can fax this form to: 217-355-1745.


Registration Information

If you use CLR Script for more than 30 days, you are required to become a registered, licensed user.  Before using CLR Script, carefully read the License Agreement.

Registered users receive the following benefits:

1.	Free minor updates via download from the Internet or $5.00 US for updates on diskette sent via postal mail.

2.	1 year of product support via email and postal mail from the date of registration.  Unregistered users may not receive a response from their support question.

3.	A say in what CLR Script can do.  You are encouraged to let me know what new features you would like to see.

4.	Your registration will ensure continued enhancements to CLR Script.

5.	You will receive a Registration Number that will remove all the ads displayed in the program.

To register your copy of CLR Script by postal mail or fax, fill out the Registration Form and send it in.  To register online, visit the CLR Script Home Page at http://www.prairienet.org/~clroth/clrscript.html.


License Agreement

Carefully read the terms and conditions before using CLR Script.  By using CLR Script, you agree to the terms and conditions stated.  If you do not agree to the stated terms and conditions, do not use CLR Script.

CLR Script is Shareware, not public domain software or free software.

Unregistered users are granted a limited license to evaluate CLR Script for 30 days.  The use of CLR Script after the 30 day evaluation period requires registration and is in violation of federal copyright laws.

One registered copy of CLR Script may be licensed to one person for use on multiple machines or for one machine for use by multiple people.  CLR Script may be used on a network provided that all workstations that have access have individual licenses.

CLR Script is registered when the registration fee has been received.

CLR Script and its associated files cannot be modified or patched in any way including but not limited to decompiling, disassembling or reverse engineering the files.

A limited license is granted to distribute CLR Script for evaluation purposes only under the following conditions:

1.	All the files must be distributed together in unmodified form.

2.	No fee, charge, donation or other compensation can be accepted or requested, except as authorized below.

a.	Electronic bulletin board and Internet site system operators may make CLR Script available for downloading as long as the above conditions are met and there is not a specific charge for downloading CLR Script.  A charge for the overall use of the bulletin board system or Internet site is permitted.

b.	Vendors of user-supported or shareware software and non-profit user groups may distribute CLR Script as long as the above conditions are met.  A charge for disk duplication and handling of CLR Script is permitted provided, that when pro-rated, is not more than five dollars US.

A letter stating that you are distributing CLR Script is recommended so as updates can be provided.

Limited Warranty

THE CLR SCRIPT SOFTWARE AND ACCOMPANYING FILES ARE PROVIDED "AS IS" AND WITHOUT WARRANTIES AS TO THE PERFORMANCE OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED.  BECAUSE OF THE VARIOUS HARDWARE AND SOFTWARE OPERATING ENVIRONMENTS, NO WARRANTY FOR A PARTICULAR PURPOSE IS OFFERED.  IN NO EVENT SHALL CARL L. ROTH BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING OUT OF THE USE OR INABILITY TO USE CLR SCRIPT EVEN IF CARL L. ROTH HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.


Build menu

The Build menu offers the following commands:

Compile	Compile the active script file.
Run	Run the active script file.


Compile command (Build menu)

Use this command to compile the active script file.  All the modified open files are automatically saved.

Shortcuts

Toolbar:

Keys:	CTRL+F7


Run command (Build menu)

Use this command to compile and run the active script file.  All the modified open files are automatically saved.

The Run command calls the function called main in the active script file.

Syntax

void main()

{

statements and function calls

}

Shortcuts

Toolbar:

Keys:	F5


How to run a script file from a shortcut

Follow these steps to run a script file from a shortcut.

1.	Create a shortcut to the program clrscrpt.exe.  Use the Windows Explorer Create Shortcut command.

2.	Modify the properties of the new shortcut.  Right-click on the shortcut and select the Properties command from the pop-up menu.

3.	In the Target edit box, add the string “/r filename” to the end of the command line.  The filename is the script file name to run.  If the filename contains spaces, surround the filename with double quotation marks.  For example: /r “long file name.csp”

4.	If you want to run the script without displaying the progress dialog window, add the switch “/h” at the end of the Target command line to run the script hidden.

5.	If appropriate, change the Start In folder name.

6.	Choose the OK button to save the properties.

7.	Rename the shortcut to something appropriate.

See Also

Command Line Options


Find command (Edit menu)

Use this command to find the specified text using the Find dialog box.

Shortcut

Keys:	Ctrl+F


Replace command (Edit menu)

Use this command to replace the specific text with different text using the Replace dialog box.

Shortcut

Keys:	Ctrl+H


Save All command (File menu)

Use this command to save all the open modified script files to their current name and directory.  When you save a script file for the first time, CLR Script displays the Save As dialog box so you can name your script file.  If you want to change the name and directory of an existing script file before you save it, choose the Save As command.


Tools menu commands

The Tools menu offers the following commands:

Window Information Finder	Find window information.


Window Information Finder command (Tools menu)

Use this command to find information about a window using the Window Information Finder dialog box.

Shortcuts

Toolbar:

Keys:	Ctrl+I


Window Information Finder dialog box

The following options allow you to find information about a window:

Finder Icon

Drag the finder icon over a window to displays it’s information.

Hide CLR Script

If checked, the CLR Script main window will be hidden to be able to find windows behind the CLR Script main window.

Caption

The caption of the window.

Class

The class name of the window.

ID

The child window id.

Close

Choose this button to close the Window Information Finder dialog box.  If the CLR Script main window was hidden, it will be shown.


Register CLR Script command (Help menu)

Use this command to register your copy of CLR Script.

See: Registration Information


Registration Number command (Help menu)

Use this command to register your copy of CLR Script using the Registration Number dialog box by entering the registration number you purchased.


Command Line Options

The following are command line options when starting CLR Script:

/r

Run the script file.  If this option is omitted, the script file will be opened for editing.

/h

Run the script file hidden.  This must be combined with /r.

/n

Start CLR Script without installing onto the computer.  No files are copied onto the computer and no registry entries are added.

/install

Reinstall CLR Script onto the computer.  If CLR Script is not already installed, this option is not needed.  This option cannot be combined with any other options.

Syntax

clrscrpt [options] [file name]


How to write and run your first script

CLR Script files are ASCII text files that contain instructions to execute.  The syntax of the instructions is very similar to the programming language ‘C’.  The instructions consist of built-in and user defined functions.  The “main” function is the first function called when running a script file.

Here is an outline for writting script files:

1.	Write the script instructions.

2.	Save the script file.

3.	Run the script file.

For your first script, we are going to display a simple “Hello World!” message.  Follow these steps to write and run your first script file:

1.	Type in the following script instructions in a new script file window:

void main()

{

MessageBox("Hello World!", "Hi!", MB_OK);

}

2.	Save your new script to a file using the Save command on the File menu.  You can use the file name “Hello World”.

3.	Run the script by using the Run command on the Build menu.  The Run command calls the user defined function “main”.

See Also

User Defined Functions

MessageBox


Built In Functions

Here is a list of the built in functions.

Grouped Programs Run Keyboard SendKeys Internet BrowseURL Windows FindWindow SetForegroundWindow SetForegroundWindowTitleSub VerifyActiveWindowText VerifyActiveWindowTitle VerifyActiveWindowTitleSub WaitWindowClosed WaitWindowTitleVisible Window Controls CheckDlgButton ClickButton ComboBox_SelectString ListBox_SelectString SetDlgItemText Messages MessageBox Flow Control exit Pause Clipboard CopyToClipboard EmptyClipboard Files CreateFile DeleteFile FileExists Strings IsEmpty itoa Registry RegCreateKey RegDeleteKey RegDeleteKeyValue RegSetKeyValueInt RegSetKeyValueString NT Services IsServiceActive Network NetUserChangePassword	Alphabetically B BrowseURL C CheckDlgButton ClickButton ComboBox_SelectString CopyToClipboard CreateFile D DeleteFile E EmptyClipboard exit F FileExists FindWindow I IsEmpty IsServiceActive itoa L ListBox_SelectString M MessageBox N NetUserChangePassword P Pause R RegCreateKey RegDeleteKey RegDeleteKeyValue RegSetKeyValueInt RegSetKeyValueString Run S SendKeys SetDlgItemText SetForegroundWindow SetForegroundWindowTitleSub V VerifyActiveWindowText VerifyActiveWindowTitle VerifyActiveWindowTitleSub W WaitWindowClosed WaitWindowTitleVisible


CLR Script Language Reference

The CLR Script language is very similar to C and the Windows API.  If you are familiar with both of those languages, the CLR Script language will seem very familiar.  If you are new to programming, the CLR Script language may be a little more difficult to use.  Just follow the many examples, and the language can be easily learned.  You can also read the many books on C and the Windows API.

Note: The CLR Script language is not the complete C language nor does it contain the complete Windows API.  It is only a subset of the features and functions of both.

Type Specifiers

Statements

Operators

Built In Functions

User Defined Functions

Constants

Comments


Type Specifiers

Type specifiers define the type of variable or function.

Syntax

int	Integer number in the range of –2,147,483,648 to 2,147,483,647.

string	String of characters up to 32,767 characters in length.

void	No value type.

HKEY	Handle to a registry key.

Remarks

String constants are defined by double quotation marks ".

Special string characters are:

\\	\ character

\"	" character

\n	new line character

\r	return character

\t	tab character

String constants can continue to the next line by ending the line with a backward slash ‘\’ character.

Example

int DisplayMessageBox(string sText)

{

MessageBox(sText, "Message", MB_OK);

return 0;

}

In this example, the function DisplayMessageBox will display the string sText in and message box then return an integer value 0


Operators

The following operators can be used with integers:

Symbol	Operation

!	Negation

|	Bitwise or

&	Bitwise and

||	Or

&&	And

+	Addition

-	Subtraction

*	Multiplication

/	Division

The following operators can be used with strings:

Symbol	Operation

+	String concatenation


Constants

The following constants are pre-defined:

Name	Value

TRUE	1

FALSE	0


Comments

A comment in the script file is all the text on a line following the characters "//".

Example

// This entire line is a comment

MessageBox("Hi!", "Hi", MB_OK);	// The rest of this line is a comment


Statements

Statements control the flow of the script.

break	The break statement breaks out of a loop.

if - else	The if statement controls conditional branching.

repeat	The repeat statement loops a specific number of times.

return	The return statement ends the execution of the function and returns control back to the calling function.

while	The while statement loops until the condition is FALSE.

#include	The #include statement includes other script files.


if - else statement

The if statement controls conditional branching.  The statement(s) following the if statement is executed if the expression evaluates non-zero.  The statement(s) following the else statement is executed if the expression evaluates to zero.

Syntax

if (expression) statement

if (expression) statement else statement

Remarks

You can define a block of statements to execute by using curly braces "{" and "}".

Example

if (IsEmpty(sText))

{

MessageBox("Please enter some text.", "Error", MB_OK);

return 0;

}

else

MessageBox(sText, "Message", MB_OK);

In this example, if the variable sText is empty, a message box is displayed to tell the user to enter some text and the function returns.  If the variable sText is not empty, the text is displayed in a message box.


repeat statement

The repeat statement loops a specific number of times.

Syntax

repeat(n) statement

Parameters

n

The number of times to loop.

Remarks

You can define a block of statements to repeat by using curly braces "{" and "}".

Example

repeat(10)

{

MessageBox("Display this message box 10 times.", "repeat", MB_OK);

}

In this example, a message box is displayed 10 times.

See Also

break


while statement

The while statement repeats a statement or a block of statements until the expression is FALSE (non-zero).

Syntax

while(expression) statement

Remarks

You can define a block of statements to loop by using curly braces "{" and "}".

Example

while(FindWindow("", "Untitled - Notepad"))

{

MessageBox("Display this message box until Notepad is closed.", "while", MB_OK);

}

In this example, a message box is displayed until Notepad is closed.

See Also

break


break statement

The break statement breaks out of a loop.

Syntax

break;

Remarks

You can only break out of a repeat or while loop.

Example

repeat(10)

{

MessageBox("Display this message box once.", "break", MB_OK);

break;

}

In this example, the message box is displayed only once because of the break.

See Also

repeat

while


return statement

The return statement ends the execution of the function and returns control back to the calling function.  The expression is evaluated and returned to the calling function.  If the expression is omitted, the return value is undefined.

If a function does not contain a return statement, the function automatically returns after the last statement.

Syntax

return;

return expression;

Remarks

The return statement always ends with a semi-colon ";".

Example

int Zero()

{

return 0;

}

In this example, the function Zero returns the value 0.


User Defined Functions

A function is the modular unit of the script file to perform a specific task.  There are user defined functions and built in functions.

User defined functions can be any name as long it is not a pre-defined built in function or variable.  The function name is case sensitive.

Syntax

type specifier name() { }

type specifier name(type specifier argument, ...) { }

The return type of the function is declared before the name of the function.

The function can contain any number of arguments separated by commas "," .

The function body is defined by the curly braces "{" and "}".

Example

int Fun(int number)

{

MessageBox("This is fun!", "Yea!", MB_OK);

return number;

}

In this example, the function "Fun" calls the pre-defined function MessageBox then returns the value contained in the argument "number".


MessageBox

The MessageBox function displays an information message box to the user.

void MessageBox(

string message,	// the message to display

string title,	// the title bar text of the message box

int options	// options

);

Parameters

message

The message text to display in the message box.

title

The title bar text to display on the message box.

options

The following options can be combined with the bit-wise or "|" operator:

One of the following button options must be included:

MB_OK	Show an OK button.

One of the following icon options can be included:

MB_ICONEXCLAMATION	Show the exclamation icon.

MB_ICONINFORMATION	Show the information icon.

Return Values

The MessageBox function does not return a value.

Example

MessageBox("Hello!", "Hi", MB_OK|MB_ICONINFORMATION);

This examples displays a message box with the text "Hello!", the title bar text "Hi", the button OK, and the icon "Information".


Pause

The Pause function pauses the script for the designated amount of time.

void Pause(

int milliseconds	// the amount of time to pause, in milliseconds

);

Parameters

milliseconds

The amount of time, in milliseconds, to pause the script.

Return Values

The Pause function does not return a value.

Example

Pause(2000);

This example pauses the script file 2 seconds.


SendKeys

The SendKeys function simulates pressing keys on the keyboard.

void SendKeys(

string keys	// the keys to press

};

Parameters

keys

The keys to simulate pressing on the keyboard.  See the Remarks section for the codes to send special keys.

Return Values

The SendKeys function does not return a value.

Remarks

Special keyboard keys are pressed by using special codes.

{alt}	The next key pressed also has the [alt] key down at the same time.

{ctrl}	The next key pressed also has the [ctrl] key down at the same time.

{shift}	The next key pressed also has the [shift] key down at the same time.

{altkey}	The [alt] key is pressed and released.

{ctrlkey}	The [ctrl] key is pressed and released.

{shiftkey}	The [shift] key is pressed and released.

{enter}	The enter key.

{space}	The space bar key.  You can also use the space character.

{tab}	The tab key.

{backspace}	The backspace key.

{up}	The up arrow key.

{down}	The down arrow key.

{left}	The left arrow key.

{right}	The right arrow key.

{pagedown}	The page down key.

{pageup}	The page up key.

{home}	The home key.

{end}	The end key.

{insert}	The insert key.

{delete}	The delete key.

{escape}	The escape [esc] key.

{pausekey}	The pause key.

{fn}	The function key n.  n can be a function key number from 1 to 24.

You can also repeat the special codes by adding a number inside the curly braces "{}".  For example: {down 5} will repeat pressing the down key 5 times in a row.

Example

SendKeys("{alt}fx");

This example presses the keys [alt]+f and x to exit a program.


VerifyActiveWindowTitle

The VerifyActiveWindowTitle function verifies the active window title text exactly to make sure the script is running as planned.

int VerifyActiveWindowTitle(

string title	// the title bar text to verify

};

Parameters

title

The title bar text to verify.

Return Values

The VerifyActiveWindowTitle function returns TRUE (non-zero) if the active window exactly matches the title bar text.  The VerifyActiveWindowTitle function returns FALSE (zero) if the active window does not exactly match the title bar text.

Remarks

The script file waits one second for the active window to match before returning FALSE.

Example

if (VerifyActiveWindowTitle("Microsoft Money"))

MessageBox("Microsoft Money is the active window title.", "Verify", MB_OK);

else

MessageBox("Microsoft Money is not the active window title.", "Verify", MB_OK);

This example verifies the active window title to see if it is "Microsoft Money" and displays the appropriate message box.

See Also

VerifyActiveWindowTitleSub, VerifyActiveWindowText


VerifyActiveWindowTitleSub

The VerifyActiveWindowTitleSub function verifies any part of the active window title text to make sure the script is running as planned.

int VerifyActiveWindowTitleSub(

string title	// the title bar text to verify

};

Parameters

title

The title bar text to verify.

Return Values

The VerifyActiveWindowTitleSub function returns TRUE (non-zero) if the active window contains the title bar text.  The VerifyActiveWindowTitleSub function returns FALSE (zero) if the active window does not contain the title bar text.

Remarks

The script file waits one second for the active window to match before returning FALSE.

Example

if (VerifyActiveWindowTitleSub("- Microsoft Money"))

MessageBox("Microsoft Money is the active program.", "Verify", MB_OK);

else

MessageBox("Microsoft Money is not the active program.", "Verify", MB_OK);

This example verifies the active window title to see if it contains "- Microsoft Money" and displays the appropriate message box.

See Also

VerifyActiveWindowTitle, VerifyActiveWindowText


VerifyActiveWindowText

The VerifyActiveWindowText function verifies the text on the active window to make sure the script is running as planned.

int VerifyActiveWindowText(

string text	// the text to verify

};

Parameters

text

The text to verify.

Return Values

The VerifyActiveWindowText function returns TRUE (non-zero) if the active window contains the text on the window.  The VerifyActiveWindowText function returns FALSE (zero) if the active window does not contain the text on the window.

Remarks

The script file waits one second for the active window to match before returning FALSE.

Example

if (VerifyActiveWindowText("Incorrect password"))

MessageBox("An incorrect password was entered.", "Verify", MB_OK);

else

MessageBox("The correct password was entered.", "Verify", MB_OK);

This example verifies the active window text to see if it contains "Incorrect password" and displays the appropriate message box.

See Also

VerifyActiveWindowTitle, VerifyActiveWindowTitleSub


FindWindow

The FindWindow function sees if a window is open that matches either the class name or window title.

int FindWindow(

string classname,	// the class name of the window to find

string title	// the title bar text of the window to find

};

Parameters

classname

The class name of the window to find.

title

The title bar text of the window to find.

Return Values

The FindWindow function returns TRUE (non-zero) if a window is found that has the class name and/or window title bar text.  The FindWindow function returns FALSE (zero) if no matching window is found.

Remarks

If both a class name and window title are used, both must match.  Otherwise, only one of the two parameters needs to match.  Enter an empty string "" to match any window.

Example

if (FindWindow("MSMoney Frame", ""))

MessageBox("Microsoft Money is running.", "Find", MB_OK);

else

MessageBox("Microsoft Money is not running.", "Find", MB_OK);

This example sees if Microsoft Money is running by finding it’s class name and displays the appropriate message box.

See Also

SetForegroundWindow, SetForegroundWindowTitleSub


SetForegroundWindow

The SetForegroundWindow function sees if a window is open that matches the class name and/or window title then brings that window to the foreground.

int SetForegroundWindow(

string classname,	// the class name of the window to bring to the foreground

string title	// the title bar text of the window to bring to the foreground

};

Parameters

classname

The class name of the window to bring to the foreground.

title

The title bar text of the window to bring to the foreground.

Return Values

The SetForegroundWindow function returns TRUE (non-zero) if a window is found that has the class name and/or window title bar text and the window is brought to the foreground.  The SetForegroundWindow function returns FALSE (zero) if no matching window is found.

Remarks

If both a class name and window title are used, both must match.  Otherwise, only one of the two parameters needs to match.  Enter an empty string "" to match any window.

Example

if (SetForegroundWindow("MSMoney Frame", ""))

MessageBox("Microsoft Money is running and is now the foreground window.", "SetForegroundWindow", MB_OK);

else

MessageBox("Microsoft Money is not running.", "SetForegroundWindow", MB_OK);

This example brings Microsoft Money to the foreground by finding it’s class name and displays the appropriate message box.

See Also

FindWindow, SetForegroundWindowTitleSub


WaitWindowTitleVisible

The WaitWindowTitleVisible function waits for the window title to become visible.

int WaitWindowTitleVisible(

string title,	// the title bar text of the window to wait for

int milliseconds	// the amount of time to wait, in milliseconds

};

Parameters

title

The exact title bar text of the window to wait for.

milliseconds

The amount of time, in milliseconds, to wait for the window to becomes visible.

Return Values

The WaitWindowTitleVisible function returns TRUE (non-zero) if the window becomes visible.  The WaitWindowTitleVisible function returns FALSE (zero) if the time elapses without window becoming visible.

Example

if (WaitWindowTitleVisible("Microsoft Money", 10000))

MessageBox("The Microsoft Money window is now visible.", "Wait", MB_OK);

else

MessageBox("The Microsoft Money window never became visible.", "Wait", MB_OK);

This example waits 10 seconds for the Microsoft Money window to become visible and displays the appropriate message box.


CheckDlgButton

The CheckDlgButton function checks or unchecks a check box on a dialog box.

int CheckDlgButton(

string text,	// the text of the check box

int setting	// the setting to make the check box

};

Parameters

text

The exact text of the check box to set.

setting

The setting to make the check box.

BST_CHECKED	Put a check mark in the check box.

BST_UNCHECKED	Remove the check mark from the check box.

Return Values

The CheckDlgButton function returns TRUE (non-zero) if the check box was found and set.  The CheckDlgButton function returns FALSE (zero) if the check box was not found.

Remarks

The CheckDlgButton waits for one second for the check box to become visible and enabled.

If there is an accelerator key associated with the check box, place an ampersand "&" before the character that is underlined as the accelerator key.

Example

if (CheckDlgButton("&Password Protect", BST_CHECK))

MessageBox("The Password Protect check box is now checked.", "CheckDlgButton", MB_OK);

else

MessageBox("The Password Protect check box does not exist.", "CheckDlgButton", MB_OK);

This example places a check mark on the Password Protect check box and displays the appropriate message box.


Run

The Run function runs a program or shortcut.

int Run(

string commandline,	// the command line to run

int show	// specifies how the window is to be shown

};

Parameters

commandline

The command line to run.

show

Specifies how the window is to be shown.

SW_SHOWMINIMIZED	Activate and show the window minimized.

SW_SHOWMINNOACTIVE	Show the window minimized.  The window that was active remains active.

SW_SHOWMAXIMIZED	Activate and show the window maximized.

SW_SHOWNORMAL	Activate and show the window in it’s normal state.

Return Values

The Run function returns TRUE (non-zero) if the program or shortcut was run.  The Run function returns FALSE (zero) if there was an error running the program or shortcut.

Example

if (Run("msmoney.exe", SW_SHOWNORMAL))

MessageBox("Microsoft Money was started.", "Run", MB_OK);

else

MessageBox("There was an error starting Microsoft Money.", "Run", MB_OK);

This example runs the program Microsoft Money (msmoney.exe) as a normal window and displays the appropriate message box if the program was started.


IsEmpty

The IsEmpty function checks to see if the string is empty or not.

int IsEmpty(

string text	// the text to check

};

Parameters

text

The text to check and see if it contains any characters or not.

Return Values

The IsEmpty function returns TRUE (non-zero) if the string does not contain any characters.  The IsEmpty function returns FALSE (zero) if the string contains characters.

Example

if (IsEmpty(sText))

MessageBox("The string is empty.", "IsEmpty", MB_OK);

else

MessageBox("The string is not empty.", "IsEmpty", MB_OK);

MB_OK);

This example checks the string variable sText to see if contains any characters and displays the appropriate message box.


CopyToClipboard

The CopyToClipboard function copies text to the Clipboard.

int CopyToClipboard(

string text	// the text to copy to the Clipboard

};

Parameters

text

The text to copy to the Clipboard.

Return Values

The CopyToClipboard function returns TRUE (non-zero) if the text was copied successfully to the Clipboard.  The CopyToClipboard function returns FALSE (zero) if there was an error copying the text to the Clipboard.

Example

if (CopyToClipboard("Hi"))

MessageBox("The text \"Hi\" is not on the Clipboard.", "Clipboard", MB_OK);

else

MessageBox("There was an error copying the text to the Clipboard.", "Clipboard", MB_OK);

MB_OK);

This example copies the text "Hi" to the Clipboard and displays the appropriate message box if the copy was successful.

See Also

EmptyClipboard


EmptyClipboard

The EmptyClipboard function empties the contents of the Clipboard.

int EmptyClipboard();

Parameters

There are no parameters.

Return Values

The EmptyClipboard function returns TRUE (non-zero) if the Clipboard was emptied.  The EmptyClipboard function returns FALSE (zero) if there was an error emptying the Clipboard contents.

Example

if (EmptyClipboard())

MessageBox("The Clipboard is now empty.", "Clipboard", MB_OK);

else

MessageBox("There was an error emptying the Clipboard contents.", "Clipboard", MB_OK);

MB_OK);

This example empties Clipboard contents and displays the appropriate message box if the contents were emptied.

See Also

CopyToClipboard


WaitWindowClosed

The WaitWindowClosed function waits until the windows with the class name and/or title bar text is closed.

void WaitWindowClosed(

string classname,	// the class name of the window

string title	// the title bar text of the window

int milliseconds	// the amount of time to wait, in milliseconds

);

Parameters

classname

The class name of the window to wait until closed.

title

The title bar text of the window to wait until closed.

milliseconds

The amount of time, in milliseconds, to wait for the window to close.

Return Values

The WaitWindowClosed function returns TRUE (non-zero) if the window is closed.  The WaitWindowClosed function returns FALSE (zero) if the time elapses without window becoming closed.

Remarks

If both a class name and window title are used, both must match.  Otherwise, only one of the two parameters needs to match.  Enter an empty string "" to match any window.

Example

if (WaitWindowClosed("", "Display Properties", 10000))

MessageBox("The Display Properties window is now closed.", "Wait", MB_OK);

else

MessageBox("The Display Properties window never closed.", "Wait", MB_OK);

This example waits 10 seconds for the Display Properties window to close and displays the appropriate message box.


exit

The exit function immediately terminates running the script.

void exit(

int returnvalue	// the return value

);

Parameters

returnvalue

The value returned to the calling program.

Return Values

The exit function does not return a value.

Example

exit(1);

This example exits the script and returns 1 to the calling program.


ClickButton

The ClickButton function simulates pressing a button control.

void ClickButton(

string text,	// the text on the button

);

Parameters

text

The text on the button.

Return Values

The ClickButton function returns TRUE (non-zero) if the button is found and pressed.  The ClickButton function returns FALSE (zero) if the button is not found.

Remarks

The ClickButton waits for one second for the button to become visible and enabled.

If there is an accelerator key associated with the button, place an ampersand "&" before the character that is underlined as the accelerator key.

Example

if (ClickButton("OK"))

MessageBox("The OK button was pressed.", "Click", MB_OK);

else

MessageBox("The OK button was not pressed.", "Click", MB_OK);

This example presses the OK button and displays the appropriate message box.


SetDlgItemText

The SetDlgItemText function sets the text in an edit control.

void SetDlgItemText(

string label,	// the static text label before the edit control

string text,	// the text to set

);

Parameters

label

The static text label before the edit control to find which edit control to set.

text

The text to set.

Return Values

The SetDlgItemText function returns TRUE (non-zero) if the text is set.  The SetDlgItemText function returns FALSE (zero) if the text is not set.

Remarks

The SetDlgItemText waits for one second for the static text label to become visible and enabled.

If there is an accelerator key associated with the static text label, place an ampersand "&" before the character that is underlined as the accelerator key.

Example

if (SetDlgItemText("&Password:", "mypassword"))

MessageBox("The password was entered.", "SetDlgItemText", MB_OK);

else

MessageBox("There was an error finding the Password edit box.", "SetDlgItemText", MB_OK);

This example sets the Password edit control and displays the appropriate message box.


#include

The #include statement includes other script files into the current script file.

Syntax

#include "filename"

Remarks

The #include statement cannot reside inside a function.

Example

#include "library.csp"

In this example, the script file library.csp is included into the current script file.


NetUserChangePassword

The NetUserChangePassword function changes the user’s password for a specified network server or domain.

void NetUserChangePassword(

string domain,	// the domain name of the server

string user,	// the user name

string oldpassword,	// the old password

string newpassword,	// the new password

);

Parameters

domain

The domain name of the server.  If it’s an empty string (""), the current user’s domain is used.

user

The user name.  If it’s an empty string (""), the current user is used.

oldpassword

The user’s old password.

newpassword

The user’s new password.

Return Values

The NetUserChangePassword function returns TRUE (non-zero) if the password was changed.  The NetUserChangePassword function returns FALSE (zero) if the password was not changed.

Remarks

The NetUserChangePassword function is only available when running under Windows NT 4.0 or later.

Example

if (NetUserChangePassword("", "", "oldone", "newone"))

MessageBox("The password was changed.", "NetUserChangePassword", MB_OK);

else

MessageBox("The password was not changed.", "NetUserChangePassword", MB_OK);

This example changes the users password to "newone" and displays the appropriate message box.


SetForegroundWindowTitleSub

The SetForegroundWindowTitleSub function sees if a window is open that contains the window title text then brings that window to the foreground.

int SetForegroundWindowTitleSub(

string title	// a part of the title bar text of the window to bring to the foreground

};

Parameters

title

A part of the title bar text of the window to bring to the foreground.

Return Values

The SetForegroundWindowTitleSub function returns TRUE (non-zero) if a window is found that contains the window title bar text and the window is brought to the foreground.  The SetForegroundWindowTitleSub function returns FALSE (zero) if no matching window is found.

Example

if (SetForegroundWindowTitleSub("- Notepad"))

MessageBox("Notepad is running and is now the foreground window.", "SetForegroundWindowTitleSub", MB_OK);

else

MessageBox("Notepad is not running.", "SetForegroundWindowTitleSub", MB_OK);

This example brings Notepad to the foreground by finding a portion of the window title bar text and displays the appropriate message box.

See Also

FindWindow, SetForegroundWindow


itoa

The itoa function converts an integer value to a string.

string itoa(

int n	// the number to convert

};

Parameters

n

The number to convert.

Return Values

The itoa function returns a string representation of the integer.

Example

MessageBox(itoa(10), "The Number 10", MB_OK);

This example displays the integer 10 as a string in a message box.


RegSetKeyValueString

The RegSetKeyValueString function sets a string value in the system registry.

int RegSetKeyValueString(

HKEY key	// the registry key

string subkey	// the registry sub key

string name	// the value name

string value	// the value

};

Parameters

key

The registry key.  It can be one of the following keys:

HKEY_CLASSES_ROOT

HKEY_CURRENT_CONFIG

HKEY_CURRENT_USER

HKEY_LOCAL_MACHINE

HKEY_USERS

HKEY_PERFORMANCE_DATA	Windows NT only

HKEY_DYN_DATA	Windows 95 and 98 only

subkey

The registry sub key.

name

The value name to set.

value

The value.

Return Values

The RegSetKeyValueString function returns TRUE (non-zero) if the registry value is set.  The RegSetKeyValueString function returns FALSE (zero) if the registry value is not set.

Example

if (RegSetKeyValueString(HKEY_CURRENT_USER, "Software\\CLR\\CLR Script\\Settings", "Test", "Test Value"))

MessageBox("The registry value was set.", "RegSetKeyValueString", MB_OK);

else

MessageBox("The registry value was not set.", "RegSetKeyValueString", MB_OK);

This example sets the registry value HKEY_CURRENT_USER\Software\CLR\CLR Script\Settings\Test to "Test Value" and displays the appropriate message box.

See Also

RegCreateKey, RegSetKeyValueInt, RegDeleteKey, RegDeleteKeyValue


RegSetKeyValueInt

The RegSetKeyValueInt function sets an integer value in the system registry.

int RegSetKeyValueInt(

HKEY key	// the registry key

string subkey	// the registry sub key

string name	// the value name

int value	// the value

};

Parameters

key

The registry key.  It can be one of the following keys:

HKEY_CLASSES_ROOT

HKEY_CURRENT_CONFIG

HKEY_CURRENT_USER

HKEY_LOCAL_MACHINE

HKEY_USERS

HKEY_PERFORMANCE_DATA	Windows NT only

HKEY_DYN_DATA	Windows 95 and 98 only

subkey

The registry sub key.

name

The value name to set.

value

The value.

Return Values

The RegSetKeyValueInt function returns TRUE (non-zero) if the registry value is set.  The RegSetKeyValueInt function returns FALSE (zero) if the registry value is not set.

Example

if (RegSetKeyValueInt(HKEY_CURRENT_USER, "Software\\CLR\\CLR Script\\Settings", "Test", 123))

MessageBox("The registry value was set.", "RegSetKeyValueInt", MB_OK);

else

MessageBox("The registry value was not set.", "RegSetKeyValueInt", MB_OK);

This example sets the registry value HKEY_CURRENT_USER\Software\CLR\CLR Script\Settings\Test to 123 and displays the appropriate message box.

See Also

RegCreateKey, RegSetKeyValueString, RegDeleteKey, RegDeleteKeyValue


RegDeleteKeyValue

The RegDeleteKeyValue function deletes a value from the system registry.

int RegDeleteKeyValue(

HKEY key	// the registry key

string subkey	// the registry sub key

string name	// the value name to delete

};

Parameters

key

The registry key.  It can be one of the following keys:

HKEY_CLASSES_ROOT

HKEY_CURRENT_CONFIG

HKEY_CURRENT_USER

HKEY_LOCAL_MACHINE

HKEY_USERS

HKEY_PERFORMANCE_DATA	Windows NT only

HKEY_DYN_DATA	Windows 95 and 98 only

subkey

The registry sub key.

name

The value name to delete.

Return Values

The RegDeleteKeyValue function returns TRUE (non-zero) if the registry value was deleted.  The RegDeleteKeyValue function returns FALSE (zero) if the registry value was not deleted.

Example

if (RegDeleteKeyValue(HKEY_CURRENT_USER, "Software\\CLR\\CLR Script\\Settings", "Test"))

MessageBox("The registry value was deleted.", "RegDeleteKeyValue", MB_OK);

else

MessageBox("The registry value was not deleted.", "RegDeleteKeyValue", MB_OK);

This example deletes the registry value HKEY_CURRENT_USER\Software\CLR\CLR Script\Settings\Test and displays the appropriate message box.

See Also

RegCreateKey, RegSetKeyValueInt, RegSetKeyValueString, RegDeleteKey


RegCreateKey

The RegCreateKey function creates a new key in the system registry.

int RegDeleteKeyValue(

HKEY key	// the registry key

string subkey	// the registry sub key to create

};

Parameters

key

The registry key.  It can be one of the following keys:

HKEY_CLASSES_ROOT

HKEY_CURRENT_CONFIG

HKEY_CURRENT_USER

HKEY_LOCAL_MACHINE

HKEY_USERS

HKEY_PERFORMANCE_DATA	Windows NT only

HKEY_DYN_DATA	Windows 95 and 98 only

subkey

The registry sub key to create.

Return Values

The RegCreateKey function returns TRUE (non-zero) if the registry key was created.  The RegCreateKey function returns FALSE (zero) if the registry key was not created.

Example

if (RegCreateKey(HKEY_CURRENT_USER, "Software\\CLR\\CLR Script\\Test"))

MessageBox("The registry key was created.", "RegCreateKey", MB_OK);

else

MessageBox("The registry key was not created.", "RegCreateKey", MB_OK);

This example creates the registry key HKEY_CURRENT_USER\Software\CLR\CLR Script\Test and displays the appropriate message box.

See Also

RegSetKeyValueInt, RegSetKeyValueString, RegDeleteKey, RegDeleteKeyValue


RegDeleteKey

The RegDeleteKey function deletes a key from the system registry.

int RegDeleteKey(

HKEY key	// the registry key

string subkey	// the registry sub key to delete

};

Parameters

key

The registry key.  It can be one of the following keys:

HKEY_CLASSES_ROOT

HKEY_CURRENT_CONFIG

HKEY_CURRENT_USER

HKEY_LOCAL_MACHINE

HKEY_USERS

HKEY_PERFORMANCE_DATA	Windows NT only

HKEY_DYN_DATA	Windows 95 and 98 only

subkey

The registry sub key to delete.

Return Values

The RegDeleteKey function returns TRUE (non-zero) if the registry key was deleted.  The RegDeleteKey function returns FALSE (zero) if the registry key was not deleted.

Example

if (RegDeleteKey(HKEY_CURRENT_USER, "Software\\CLR\\CLR Script\\Test"))

MessageBox("The registry key was deleted.", "RegDeleteKey", MB_OK);

else

MessageBox("The registry key was not deleted.", "RegDeleteKey", MB_OK);

This example deletes the registry key HKEY_CURRENT_USER\Software\CLR\CLR Script\Test and displays the appropriate message box.

See Also

RegCreateKey, RegSetKeyValueInt, RegSetKeyValueString, RegDeleteKeyValue


CreateFile

The CreateFile function creates a new file.  This function fails if the specified file already exists.  Use the function FileExists to test if the file already exists.

int CreateFile(

string filename	// the name of the file to create

};

Parameters

filename

The name of the file to create.

Return Values

The CreateFile function returns TRUE (non-zero) if the file was created.  The CreateFile function returns FALSE (zero) if the file was not created.

Example

if (CreateFile("c:\\temp\\trash.txt"))

MessageBox("The file trash.txt was created in the c:\\temp folder.", "CreateFile", MB_OK);

else

MessageBox("The file trash.txt was not created.", "CreateFile", MB_OK);

This example creates the file trash.txt in the c:\temp folder and displays the appropriate message box.

See Also

DeleteFile, FileExists


DeleteFile

The DeleteFile function deletes an existing file.  This function fails if the specified file does not exist.  Use the function FileExists to test if the file already exists.

int DeleteFile(

string filename	// the name of the file to delete

};

Parameters

filename

The name of the file to delete.

Return Values

The DeleteFile function returns TRUE (non-zero) if the file was deleted.  The DeleteFile function returns FALSE (zero) if the file was not deleted.

Example

if (DeleteFile("c:\\temp\\trash.txt"))

MessageBox("The file trash.txt was deleted from the c:\\temp folder.", "DeleteFile", MB_OK);

else

MessageBox("The file trash.txt was not deleted.", "DeleteFile", MB_OK);

This example deletes the file trash.txt from the c:\temp folder and displays the appropriate message box.

See Also

CreateFile, FileExists


FileExists

The FileExists function tests to see if a file exists.

int FileExists(

string filename	// the name of the file to test

};

Parameters

filename

The name of the file to test for existence.

Return Values

The FileExists function returns TRUE (non-zero) if the file exists.  The FileExists function returns FALSE (zero) if the file does not exist.

Example

if (FileExists("c:\\temp\\trash.txt"))

MessageBox("The file trash.txt exists in the c:\\temp folder.", "FileExists", MB_OK);

else

MessageBox("The file trash.txt does not exist in the c:\\temp folder.", "FileExists", MB_OK);

This example tests to see if the file trash.txt exists in the c:\temp folder and displays the appropriate message box.

See Also

CreateFile, DeleteFile


BrowseURL

The BrowseURL function opens your web browser to the specified web page.

int BrowseURL(

string sURL	// the URL to open

int bNewWindow	// open in a new browser window or an existing browser window

};

Parameters

sURL

The URL to open.

bNewWindow

If TRUE (non-zero), open the URL in a new browser window.

If FALSE (zero), open the URL in an existing browser window.  If a browser window is not already open, a new browser window will be opened.

Return Values

The BrowseURL function returns TRUE (non-zero) if the URL was opened.  The BrowseURL function returns FALSE (zero) if the URL was not opened.

Remarks

The BrowseURL function tests to see if you are currently connected to the Internet.  If you are not connected to the Internet and you are not currently working off-line, the function will return FALSE (zero).

Example

if (BrowseURL("http://www.microsoft.com", TRUE))

MessageBox("The Microsoft home page was opened in a new window.", "BrowseURL", MB_OK);

else

MessageBox("Unable to open the Microsoft home page.  You are probably not connected to the Internet.", "BrowseURL", MB_OK);

This example opens the Microsoft home page in a new browser window and displays the appropriate message box.


ComboBox_SelectString

The ComboBox_SelectString function selects text in a combo box control.

void ComboBox_SelectString(

string label,	// the static text label before the combo box control

string text,	// the text to select

);

Parameters

label

The static text label before the combo box control to find which combo box control to set.

text

The text to select.

Return Values

The ComboBox_SelectString function returns TRUE (non-zero) if the text is selected.  The ComboBox_SelectString function returns FALSE (zero) if the text is not selected.

Remarks

The ComboBox_SelectString waits for one second for the static text label to become visible and enabled.

If there is an accelerator key associated with the static text label, place an ampersand "&" before the character that is underlined as the accelerator key.

Example

if (ComboBox_SelectString("&Combo Box:", "Item 1"))

MessageBox("Item 1 was selected.", "ComboBox_SelectString", MB_OK);

else

MessageBox("There was an error finding the combo box or the string is not in the list.", "ComboBox_SelectString", MB_OK);

This example selects Item 1 in the combo box control and displays the appropriate message box.

See Also

ListBox_SelectString


ListBox_SelectString

The ListBox_SelectString function selects text in a list box control.

void ListBox_SelectString(

string label,	// the static text label before the list box control

string text,	// the text to select

);

Parameters

label

The static text label before the list box control to find which list box control to set.

text

The text to select.

Return Values

The ListBox_SelectString function returns TRUE (non-zero) if the text is selected.  The ListBox_SelectString function returns FALSE (zero) if the text is not selected.

Remarks

The ListBox_SelectString waits for one second for the static text label to become visible and enabled.

If there is an accelerator key associated with the static text label, place an ampersand "&" before the character that is underlined as the accelerator key.

Example

if (ListBox_SelectString("&List:", "Item 1"))

MessageBox("Item 1 was selected.", "ListBox_SelectString", MB_OK);

else

MessageBox("There was an error finding the list box or the string is not in the list.", "ListBox_SelectString", MB_OK);

This example selects Item 1 in the list box control and displays the appropriate message box.

See Also

ComboBox_SelectString


IsServiceActive

The IsServiceActive function checks the system to see if a service is active.

void IsServiceActive(

string service,	// the service name to check

);

Parameters

service

The service name to check.  Use the display name of the service as listed in the Services control panel.

Return Values

The IsServiceActive function returns TRUE (non-zero) if the service is active.  The IsServiceActive function returns FALSE (zero) if the service is not active.

Remarks

The IsServiceActive function is only available when running under Windows NT 4.0 or later.

Example

if (IsServiceActive("Spooler"))

MessageBox("The spooler is running.", "IsServiceActive", MB_OK);

else

MessageBox("The spooler is not running.", "IsServiceActive", MB_OK);

This example checks to see if the spooler service is running and displays the appropriate message.


Registration Number dialog box

The following options allow you to register your program:

Name

Enter the name exactly as provided.

Number

Enter the number exactly as provided.

Register

Choose this button to purchase your copy of the program.


Your evaluation period has ended.

Select one of the following options since the program evaluation period has ended:

Register

Choose thie button to register your copy of the program using the Registration Number dialog box.

Uninstall

Choose this button to remove the program from your computer.

Continue

Choose this button to continue to evaluate the program.